package cn.cds.withyou.lib.model;

import android.database.Cursor;

import java.io.Serializable;
import java.sql.Timestamp;

import cn.cds.withyou.lib.Constants;

/**
 * <p> Description: </p>
 * <p/>
 * <p> Copyright: Copyright (c) 2016 </p>
 *
 * @author: Json.Lee
 * @Version: 1.0
 * @CreateTime: 27/4/2016 23:12
 */
public class VIPRequestDto implements Serializable, Comparable<VIPRequestDto> {

    private String id;
    private String name;
    private String gender;
    private String phone;
    private String qq;
    private String college;
    private String profession;
    private String passed;
    private long createTime;

    public VIPRequestDto () {

    }

    public VIPRequestDto (Cursor result) {
        id = result.getString(result.getColumnIndex(Constants._ID));
        name = result.getString(result.getColumnIndex(Constants.VIPRequest._NAME_ITEM));
        gender = result.getString(result.getColumnIndex(Constants.VIPRequest._GENDER_ITEM));
        phone = result.getString(result.getColumnIndex(Constants.VIPRequest._PHONE_ITEM));
        qq = result.getString(result.getColumnIndex(Constants.VIPRequest._QQ_ITEM));
        college = result.getString(result.getColumnIndex(Constants.VIPRequest._COLLEGE_ITEM));
        profession = result.getString(result.getColumnIndex(Constants.VIPRequest._PROFESSION_ITEM));
        passed = result.getString(result.getColumnIndex(Constants.VIPRequest._PASSED_ITEM));
        createTime = Timestamp.valueOf(result.getString(result.getColumnIndex(Constants.VIPRequest._CREATE_TIME))).getTime();
    }

    public static final String ACCEPT = "Y";
    public static final String REJECT = "N";
    public static final String UNHANDLE = "";

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    public String getPassed() {
        return passed;
    }

    public void setPassed(String passed) {
        this.passed = passed;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    @Override
    public int compareTo(VIPRequestDto another) {
        int zelf = UNHANDLE.equals(passed) ? 0 : 1;
        int other = UNHANDLE.equals(another.passed) ? 0 : 1;
        if (zelf - other > 0) {
            return 1;
        } else if (zelf - other < 0) {
            return -1;
        } else {
            return (int) (another.createTime - createTime);
        }
    }
}
